package com.spotmanger.project.modular.vectordata.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spotmanger.project.common.core.utils.DataResult;
import com.spotmanger.project.modular.vectordata.entity.VectordataMineEntity;
import com.spotmanger.project.modular.vectordata.service.VectordataMineService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;




/**
 * 生产、废弃矿山的边界矢量信息表。记录了矿区边界矢量的存储地址，该边界所关联的项目和边界建立的时间，可通过时间和项目对边界进行检索。
 *
 * @author leihao
 * @email 1321451088@qq.com
 * @date 2021-09-21 18:18:34
 */
@Controller
@RequestMapping("/")
public class VectordataMineController {
    @Autowired
    private VectordataMineService vectordataMineService;


    /**
    * 跳转到页面
    */
    @GetMapping("/index/vectordataMine")
    public String vectordataMine() {
        return "vectordatamine/list";
        }

    @ApiOperation(value = "新增")
    @PostMapping("vectordataMine/add")
    @RequiresPermissions("vectordataMine:add")
    @ResponseBody
    public DataResult add(@RequestBody VectordataMineEntity vectordataMine){
        vectordataMineService.save(vectordataMine);
        return DataResult.success();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("vectordataMine/delete")
    @RequiresPermissions("vectordataMine:delete")
    @ResponseBody
    public DataResult delete(@RequestBody @ApiParam(value = "id集合") List<String> ids){
        vectordataMineService.removeByIds(ids);
        return DataResult.success();
    }

    @ApiOperation(value = "更新")
    @PutMapping("vectordataMine/update")
    @RequiresPermissions("vectordataMine:update")
    @ResponseBody
    public DataResult update(@RequestBody VectordataMineEntity vectordataMine){
        vectordataMineService.updateById(vectordataMine);
        return DataResult.success();
    }

    @ApiOperation(value = "查询分页数据")
    @PostMapping("vectordataMine/listByPage")
    @RequiresPermissions("vectordataMine:list")
    @ResponseBody
    public DataResult findListByPage(@RequestBody VectordataMineEntity vectordataMine){
        Page page = new Page(vectordataMine.getPage(), vectordataMine.getLimit());
        LambdaQueryWrapper<VectordataMineEntity> queryWrapper = Wrappers.lambdaQuery();
        //查询条件示例
        //queryWrapper.eq(VectordataMineEntity::getId, vectordataMine.getId());
        IPage<VectordataMineEntity> iPage = vectordataMineService.page(page, queryWrapper);
        return DataResult.success(iPage);
    }

}
